package club.cearnach.entity;

import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;

/**
 * @author 阮胜
 * @date 2018/5/10 14:28
 */
@Data
@Entity
@DynamicUpdate
@DynamicInsert
public class MovieType implements Serializable {
    private static final long serialVersionUID = -1982972689953426988L;
    @Id
    @Column(name = "movie_type_id")
    @GeneratedValue
    private Integer id;

    @NotBlank
    @Column(name = "movie_type_name", unique = true)
    private String typeName;

    @Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
    private Date updateDate;

    @Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", updatable = false)
    private Date createDate;

    public MovieType() {
    }

    public MovieType(String typeName) {
        this.typeName = typeName;
    }
}
